﻿<!-- 
 Family Lines code is provided using the Apache License V2.0, January 2004 http://www.apache.org/licenses/
  
 -->
<UserControl x:Class="KBS.FamilyLines.Controls.EventDetails"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:properties="clr-namespace:KBS.FamilyLines.Properties"
             xmlns:local="clr-namespace:KBS.FamilyLines"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
>

    <UserControl.Resources>
        <ResourceDictionary>
            <local:NotConverter x:Key="NotConverter"/>
            <local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        </ResourceDictionary>
    </UserControl.Resources>

    <StackPanel Margin="0,0,0,5" HorizontalAlignment="Stretch">

        <!-- Event date -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Label MouseEnter="Label_MouseEnter" 
                   MouseLeave="Label_MouseLeave" 
                   Grid.Row="0" 
                   Grid.Column="0" 
                   Content="{Binding Path=EventDateName}"  
                   Target="{Binding ElementName=DateEditTextBox, Mode=OneWay}" 
                   MouseLeftButtonUp="ChangeDescriptorForward" 
                   MouseRightButtonUp="ChangeDescriptorBackward" 
                   Foreground="{DynamicResource InputFontColor}" 
                   IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" />
            
            <Label Grid.Row="0" 
                   Grid.Column="1" 
                   Margin="-6,0,0,0" 
                   Content="{Binding Path=DateDescriptor}" 
                   Foreground="{DynamicResource InputFontColor}" />

            <TextBox Grid.Row="1" 
                     Grid.ColumnSpan="2" 
                     TextWrapping="NoWrap" 
                     x:Name="DateEditTextBox" 
                     Width="135" 
                     HorizontalAlignment="Left" 
                     Margin="5,0,0,0" 
                     IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                     Text="{Binding Path=EventDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" 
                     ToolTip="" 
                     ToolTipOpening="ToolTip_All"/>

        </Grid>

        <!-- Event Place -->
        <Label Content="{Binding Path=EventPlaceName}"  
                   Target="{Binding ElementName=PlaceEditTextBox, Mode=OneWay}" 
                   Foreground="{DynamicResource InputFontColor}" />

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
<!-- TODO: should UpdateSourceTrigger be 'LostFocus'? The code was written with that assumption? -->
            <TextBox TextWrapping="NoWrap" 
                         x:Name="PlaceEditTextBox" 
                         Text="{Binding Path=EventPlace, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                         Width="230" 
                         Margin="5,0,0,0" 
                         IsEnabled="{Binding Path=IsLocked, Converter={StaticResource NotConverter}, Mode=Default}" 
                         Grid.Column="0" 
                         Height="21.96" 
                         ToolTip="" 
                         ToolTipOpening="ToolTip_All"/>
            <Image Margin="4,0,0,0" 
                       Opacity="0.4" 
                       HorizontalAlignment="Center" 
                       VerticalAlignment="Center" 
                       Source="..\Images\Search.png" 
                       Grid.Column="1" 
                       Width="16" 
                       Height="16" />
            <Image Margin="4,0,0,0" 
                       Cursor="Hand" 
                       x:Name="PlaceSearch" 
                       MouseLeftButtonUp="SearchMapEventPlace" 
                       HorizontalAlignment="Center" 
                       Visibility="{Binding Path=HasEventPlace, Converter={StaticResource BoolToVisibilityConverter}, Mode=Default}" 
                       VerticalAlignment="Center" 
                       Source="..\Images\Search.png" 
                       Grid.Column="1" 
                       Width="16" 
                       Height="16" 
                       ToolTip="{x:Static properties:Resources.MapToolTip}" />
        </Grid>

        <!-- (source) -->
        
    </StackPanel>
</UserControl>
